/**
 * @description localStorage方法定义
 * @class Local
 */
 class Local {
  get (key) {
    return JSON.parse(localStorage.getItem(key))
  }
  set (key, value) {
    localStorage.setItem(key, JSON.stringify(value))
  }
  remove (key) {
    localStorage.removeItem(key)
  }
  clear () {
    localStorage.clear()
  }
}
/**
 * @description sessionStorage方法定义
 * @class Session
 */
class Session {
  get (key) {
    try {
      return JSON.parse(sessionStorage.getItem(key))
    } catch (e) {
      return sessionStorage.getItem(key)
    }
  }
  set (key, value) {
    sessionStorage.setItem(key, JSON.stringify(value))
  }
  remove (key) {
    sessionStorage.removeItem(key)
  }
  clear () {
    sessionStorage.clear()
  }
}
const Storage = {
  Local: new Local(),
  Session: new Session()
}
export default Storage
